<?php


namespace App\Http\Controllers\Api;


use App\Services\Business\Models\Recommend;
use Illuminate\Http\Request;

class RecommendController extends BaseController
{


    public function storeRecommend(Request $request,string $type,int $id)
    {
        $data = $request->input('recommends',[]);
        $modal = 'App\Services\Business\Models\\' . ucfirst($type);
        $modal = new $modal;
        $resource = $modal::find($id);

        $resource->recommends()->createMany($data);
        return $this->success(__('添加推荐成功'));

    }

    public function deleteRecommend(Request $request)
    {
        $ids =$request->input('ids',[]);
        if(!$ids){
            return $this->error(__('参数有错'));
        }
        Recommend::destroy($ids);
        return $this->success(__('取消推荐成功'));

    }


}
